#include<stdio.h>
#include<math.h>
using namespace std;
int aa[105];
int main()
{
	int n = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &aa[i]);
	}
	
	int avg = 0;
	for (int i = 1; i <= n; i++)
	{
		avg += aa[i];
	}
	avg /= n;
	for (int i = 1; i <= n; i++)
	{
		aa[i] -= avg;
	}
	int i = 1, j = n;
	while (aa[i] == 0 && i < n)
	{
		i++;
	}
	while (aa[j] == 0 && j > 1)
	{
		j--;
	}
	
	int js = 0;
	while (i < j)
	{
		aa[i + 1] += aa[i];
		aa[i] = 0;
		js++;
		i++;
		while (aa[i] == 0 && i < j)
		{
			i++;
		}
	}
	
	printf("%d\n", js);
	
	return 0;
}
